package com.juzi.wopu.web;

import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;

public abstract class CRUDAaction<T> extends BaseAction implements ModelDriven<T>,Preparable{
	
	private static final long serialVersionUID = 1L;
	
	protected Long id;
	
	protected String companyName;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	public String getCompanyName() {
		return companyName;
	}
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	
	/**
	 * 查询所有的成功后就返回成功页面
	 */
	@Override
	@InputConfig(methodName="execute")
	public String execute() throws Exception {
		list();
		return SUCCESS;
	}

	/**
	 * 获取所有的内容
	 */
	protected abstract void list();

	/**
	 * 添加
	 * @return
	 * @throws Exception
	 */
	public abstract String save() throws Exception;
	
	/**
	 * 删除
	 * @return
	 * @throws Exception
	 */
	public abstract String delete() throws Exception;
	
	/**
	 * input前置方法
	 * 主要做回显功能
	 * @throws Exception
	 */
	public abstract void prepareInput() throws Exception;
	
	/**
	 * save前置方法
	 * 保证在保存后把能保存成功
	 * @throws Exception
	 */
	public abstract void prepareSave() throws Exception;
	
	@Override
	public void prepare() throws Exception {
		
	}
}